package com.charging.controller.app;

import com.charging.bean.Person;
import io.swagger.models.auth.In;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * @author 冯政尚
 * @data 2019/10/11 17:58
 */
public class Demo {

    public static List<Person> listSort(List<Person> list) {
        Collections.sort(list, new Comparator<Person>() {
            @Override
            public int compare(Person o1, Person o2) {
                //降序，o1,o2反过来则升序
                return o1.getId().compareTo(o2.getId());
            }
        });
        System.out.println("1233:"+list);
        return list;
    }

    public static void main(String[] args) {
        Person person = new Person();
        float a = Float.parseFloat("0.5400");
        person.setId((int)a);
        person.setName("xiao3");
        person.setAge(3);
        System.out.println("person:"+person);
        Person person1 = new Person();
        float b = Float.parseFloat("10.0");
        person1.setId((int)b);
        person1.setName("xiao2");
        person1.setAge(2);
        Person person2 = new Person();

        float c = Float.parseFloat("10.7");
        person2.setId((int)c);
        person2.setName("xiao");
        person2.setAge(1);
        Person person3 = new Person();
        float d = Float.parseFloat("11.8");
        person3.setId((int)d);
        person3.setName("xiao7");
        person3.setAge(7);
        Person person4 = new Person();
        float e = Float.parseFloat("165.5270");
        person4.setId((int)e);
        person4.setName("xiao5");
        person4.setAge(5);
        Person person5 = new Person();
        float f = Float.parseFloat("165.6780");
        person5.setId((int)f);
        person5.setName("xiao6");
        person5.setAge(5);
        Person person6 = new Person();
        float g = Float.parseFloat("5.0");
        person6.setId((int)g);
        person6.setName("xiao7");
        person6.setAge(5);
        List<Person> list = new ArrayList<>();
         list.add(person);
         list.add(person1);
         list.add(person2);
         list.add(person3);
         list.add(person4);
         list.add(person5);
         list.add(person6);
         listSort(list);
    }


}
